package tda366.tilemap;

import java.awt.Canvas;
import java.awt.Dimension;
import java.awt.Graphics;

@SuppressWarnings("serial")
public class TileMapView extends Canvas {
	
	private Dimension tileSize = new Dimension(20,20);
	private Dimension modelSize = new Dimension(20,20);
	private TileMapModel model;

	public TileMapView(){
		setSize(tileSize.width*modelSize.width,
				tileSize.height * modelSize.height);
		model = new TileMapModel();
		repaint();
	}
	
	public TileMapView(TileMapModel model){
		setSize(tileSize.width*modelSize.width,
				tileSize.height*modelSize.height);
		this.model=model;
		repaint();
	}
	
	public void paint(Graphics g){
		for(int i = 0; i < modelSize.width; i++){
			for(int j = 0; j < modelSize.height;j++){
				ITile tile = model.getTileMapState(i,j);
						tile.draw(
								g, 
								i * tileSize.width,
								j * tileSize.height,
								tileSize);
				
			}
		}
		
	}
}
